package com.haixiaoke.saas.repository.service.impl;

import com.haixiaoke.saas.repository.mapper.UserMapper;
import com.haixiaoke.saas.repository.pojo.User;
import com.haixiaoke.saas.repository.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author Dell
 * @Date 2023/10/13
 **/
@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public int updateMobileDevicesId(String mobileDevicesId, String userId) {
        return userMapper.updateMobileDevicesId(mobileDevicesId,userId);
    }

    @Override
    public List<User> selectMobileDevicesIdByOrgId(Long orgId) {
        return userMapper.selectMobileDevicesIdByOrgId(orgId);
    }

    @Override
    public List<User> selectUserByTypeAndOrgId(Integer type, Long orgId) {
        return userMapper.selectUserByTypeAndOrgId(type,orgId);
    }

    @Override
    public User selectUserByUserId(String userId) {
        User user = userMapper.selectUserByUserId(userId);
        String departmentName = userMapper.selectDepartmentByUserId(user.getDepId());
        user.setDepartmentName(departmentName);
        return user;
    }
}
